Skip to content

Conversation

azych
Copy link
Contributor

@azych azych commented Feb 27, 2025

This adds create command that enables creating a new catalog (ClusterCatalog) in the cluster.

create has the following signature and flags:

Usage:
  operator olmv1 create catalog <catalog_name> <image_source_ref> [flags]

Aliases:
  catalog, catalogs <catalog_name> <image_source_ref>

Flags:
      --available                          availability of the catalog (default true)
      --cleanup-timeout duration           the amount of time to wait before cancelling cleanup (default 1m0s)
  -h, --help                               help for catalog
      --labels stringToString              catalog labels (default [])
      --priority int32                     priority of the catalog
      --source-poll-interval-minutes int   source poll interval [in minutes] (default 10)

Example walkthrough:

➜  kubectl get clustercatalogs
No resources found

➜  go run *.go olmv1 create catalog operatorhubio "quay.io/operatorhubio/catalog:latest"
catalog "operatorhubio" created

➜  kubectl get clustercatalogs
NAME            LASTUNPACKED   SERVING   AGE
operatorhubio   10s            True      16s

➜  kubectl get clustercatalogs -o yaml
apiVersion: v1
items:
- apiVersion: olm.operatorframework.io/v1
  kind: ClusterCatalog
  metadata:
    creationTimestamp: "2025-02-27T10:40:29Z"
    finalizers:
    - olm.operatorframework.io/delete-server-cache
    generation: 1
    labels:
      olm.operatorframework.io/metadata.name: operatorhubio
    name: operatorhubio
    resourceVersion: "7546"
    uid: 2d77860a-d406-40a9-b87b-4ad0eeca0ef6
  spec:
    availabilityMode: Available
    priority: 0
    source:
      image:
        pollIntervalMinutes: 10
        ref: quay.io/operatorhubio/catalog:latest
      type: Image
  status:
    conditions:
    - lastTransitionTime: "2025-02-27T10:40:39Z"
      message: Successfully unpacked and stored content from resolved source
      observedGeneration: 1
      reason: Succeeded
      status: "True"
      type: Progressing
    - lastTransitionTime: "2025-02-27T10:40:39Z"
      message: Serving desired content from resolved source
      observedGeneration: 1
      reason: Available
      status: "True"
      type: Serving
    lastUnpacked: "2025-02-27T10:40:35Z"
    resolvedSource:
      image:
        ref: quay.io/operatorhubio/catalog@sha256:873b66abb5b376b28f2727a84dab463e1a62dc05e3c7a3e70402376f03e41e83
      type: Image
    urls:
      base: https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio
kind: List
metadata:
  resourceVersion: ""

➜  go run *.go olmv1 create catalog operatorhubio2 "quay.io/operatorhubio/catalog:latest" --labels=test=case2 --available=true --priority=10 --source-poll-interval-minutes=2
catalog "operatorhubio2" created

➜  kubectl get clustercatalogs operatorhubio2 -o yaml
apiVersion: olm.operatorframework.io/v1
kind: ClusterCatalog
metadata:
  creationTimestamp: "2025-02-27T10:41:26Z"
  finalizers:
  - olm.operatorframework.io/delete-server-cache
  generation: 1
  labels:
    olm.operatorframework.io/metadata.name: operatorhubio2
    test: case2
  name: operatorhubio2
  resourceVersion: "7645"
  uid: 1740243e-c69d-4012-bb89-592f24e2e681
spec:
  availabilityMode: Available
  priority: 10
  source:
    image:
      pollIntervalMinutes: 2
      ref: quay.io/operatorhubio/catalog:latest
    type: Image
status:
  conditions:
  - lastTransitionTime: "2025-02-27T10:41:45Z"
    message: Successfully unpacked and stored content from resolved source
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: Progressing
  - lastTransitionTime: "2025-02-27T10:41:45Z"
    message: Serving desired content from resolved source
    observedGeneration: 1
    reason: Available
    status: "True"
    type: Serving
  lastUnpacked: "2025-02-27T10:41:42Z"
  resolvedSource:
    image:
      ref: quay.io/operatorhubio/catalog@sha256:873b66abb5b376b28f2727a84dab463e1a62dc05e3c7a3e70402376f03e41e83
    type: Image
  urls:
    base: https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio2

➜ go run *.go olmv1 create catalog operatorhubio-notavailable "quay.io/operatorhubio/catalog:latest" --labels=test=case --available=false --priority=11 --source-poll-interval-minutes=3
catalog "operatorhubio-notavailable" created

➜ kubectl get clustercatalogs
NAME                         LASTUNPACKED   SERVING   AGE
operatorhubio                2m11s          True      2m17s
operatorhubio-notavailable                  False     6s
operatorhubio2               64s            True      80s

➜ go run *.go olmv1 create catalog operatorhubio-wrongimg "quay.io/operatorhubio/catalog:00"
failed to create catalog "operatorhubio-wrongimg": context deadline exceeded
exit status 1

➜  kubectl get clustercatalogs
NAME                         LASTUNPACKED   SERVING   AGE
operatorhubio                3m59s          True      4m5s
operatorhubio-notavailable                  False     114s
operatorhubio2               2m52s          True      3m8s

2nd part of operator-framework/operator-controller#1770 (first one is here: #219)
closes operator-framework/operator-controller#1770

@openshift-ci openshift-ci bot requested review from jmrodri and joelanford February 27, 2025 10:55
@azych
Copy link
Contributor Author

azych commented Feb 27, 2025

I'm holding off on unit tests until two potential discussion points above (#220 (comment), #220 (comment)) are resolved

@azych azych force-pushed the olmv1-create-catalog branch from 742ac02 to 65df903 Compare February 28, 2025 10:10
@azych azych changed the title Add command to create a new olmv1 catalog ✨ Add command to create a new olmv1 catalog Feb 28, 2025
Copy link
Contributor

@ankitathomas ankitathomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 3, 2025
@LalatenduMohanty
Copy link
Member

LalatenduMohanty commented Mar 3, 2025

Tested the PR successfully

$ kubectl operator olmv1 create catalog operatorhubio quay.io/operatorhubio/catalog:latest
catalog "operatorhubio" created

$ kubectl get clustercatalog
NAME            LASTUNPACKED   SERVING   AGE
operatorhubio   5s             True      11s


$ kubectl describe clustercatalog operatorhubio
Name:         operatorhubio
Namespace:    
Labels:       olm.operatorframework.io/metadata.name=operatorhubio
Annotations:  <none>
API Version:  olm.operatorframework.io/v1
Kind:         ClusterCatalog
Metadata:
  Creation Timestamp:  2025-03-03T23:30:05Z
  Finalizers:
    olm.operatorframework.io/delete-server-cache
  Generation:        1
  Resource Version:  1233
  UID:               0080e320-6ffe-4b69-84b3-1c0606695d09
Spec:
  Availability Mode:  Available
  Priority:           0
  Source:
    Image:
      Poll Interval Minutes:  10
      Ref:                    quay.io/operatorhubio/catalog:latest
    Type:                     Image
Status:
  Conditions:
    Last Transition Time:  2025-03-03T23:30:13Z
    Message:               Successfully unpacked and stored content from resolved source
    Observed Generation:   1
    Reason:                Succeeded
    Status:                True
    Type:                  Progressing
    Last Transition Time:  2025-03-03T23:30:13Z
    Message:               Serving desired content from resolved source
    Observed Generation:   1
    Reason:                Available
    Status:                True
    Type:                  Serving
  Last Unpacked:           2025-03-03T23:30:11Z
  Resolved Source:
    Image:
      Ref:  quay.io/operatorhubio/catalog@sha256:d4fa5c7e705a13e6f3e0a21d9d4e8a154a0e839cda5e3288c6a2edcb04b0749a
    Type:   Image
  Urls:
    Base:  https://catalogd-service.olmv1-system.svc/catalogs/operatorhubio
Events:    <none>

@azych azych force-pushed the olmv1-create-catalog branch from b5aef3b to a780b3d Compare March 4, 2025 14:31
Copy link
Member

@LalatenduMohanty LalatenduMohanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 5, 2025
@perdasilva perdasilva added this pull request to the merge queue Mar 5, 2025
Merged via the queue into operator-framework:main with commit adb5f78 Mar 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend kubectl-operator to add/remove ClusterCatalogs

5 participants